<?php

namespace App\Extensions\Grid;

use App\Extensions\Grid\Displayers;
use Encore\Admin\Grid\Column;

/**
 * Trait ExtendDisplay.
 *
 * @method $this layerShow($callback = '', $title = '详情', $width = '1000', $height = '800')
 * @method $this helpTip($callback = '', $default = '')
 * @method $this modalLink($title, $callback = '')
 * @method $this dateFormat($format = '')
 * @method $this nowrap($minWidth = '', $width = '')
 * @method $this tooltip($callback = '', $config = [])
 * @method $this displayLabel($callback = '', $style = 'success')
 * @method $this layerFileShow($callback = '', $title = '详情', $width = '1000', $height = '800')
 * @method $this linkEdit($href = '', $target = '_self')
 *
 */
class EColumn extends Column
{
    /**
     * @var array
     */
    private static array $local_displayers = [
        'modal'         => Displayers\EModal::class,
        'layerShow'     => Displayers\LayerShow::class,
        'dateFormat'    => Displayers\DateFormat::class,
        'helpTip'       => Displayers\HelpTip::class,
        'modalLink'     => Displayers\ModalLink::class,
        'link'          => Displayers\Link::class,
        'linkEdit'      => Displayers\LinkEdit::class,
        'limit'         => Displayers\Limit::class,
        'nowrap'        => Displayers\Nowrap::class,
        'copyable'      => Displayers\Copyable::class,
        'displayLabel'  => Displayers\DisplayLabel::class,
        'layerFileShow' => Displayers\LayerFileShow::class
    ];

    public function __construct($name, $label)
    {
        self::localExtend();
        return parent::__construct($name, $label);
    }

    private static function localExtend()
    {
        self::$displayers = array_merge(self::$displayers, self::$local_displayers);
    }
}
